package com.feicheng.controller.shop.wx.app.client;


import com.feicheng.common.exception.SystemException;
import com.feicheng.common.result.ResultInfo;
import com.feicheng.persistence.entity.Client;
import com.feicheng.service.IFClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cailongyang
 * @since 2021-12-02
 */
@RestController("/wx/app/client")
@RequestMapping("/wx/app/client")
public class ClientController {

    @Autowired
    IFClientService iFClientService;

    @GetMapping("/qCode")
    public ResultInfo getQCode(Integer clientId, Integer storeId) {
        return iFClientService.getQcode(clientId, storeId);
    }

    @PutMapping("/info")
    public ResultInfo update(Client client) {
        if (null == client.getClientId()) {
            // TODO 客户ID缺失
            throw new SystemException("客户ID缺失");
        }
        return iFClientService.updateClient(client);
    }
}
